package Static.practice.Product;

public class Product {
    private String name;
    private double price;
    private int scanCode;
    private int num;
    private static int count = 999;


    public Product(String name, double price) {
        this.name = name;
        this.price = price;
        Product.count++;
        this.scanCode += count;
    }

    public void changePrice(double price) {
        this.price = price;
    }

    boolean buy(int num) {
        if (this.num < num)
            return false;
        else {
            this.num -= num;
            return true;
        }
    }

    public String getInfo() {
        return "--- 产品信息 ---" + "\n" + "名称：" + this.getName()
                + "\n" + "编码：" + this.getScanCode() + "\n" + "价格：" + this.getPrice() + "元";
    }

    public int getNum() {
        return num;
    }

    public int getScanCode() {
        return scanCode;
    }

    public double getPrice() {
        return price;
    }

    public String getName() {
        return name;
    }

    public void setNum(int num) {
        this.num = num;
    }
}
